package com.example.springbootjpa.dao;

import com.example.springbootjpa.entity.UcUserAccountNet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @className: UcUserAccountNetDao
 * @description:
 * @author: li
 * @create: 2019-01-28 16:55
 **/
public interface UcUserAccountNetDao extends JpaRepository<UcUserAccountNet,Long> {

    List<UcUserAccountNet> findByUserName(String userName);
    
    /** 
    * @Description: 这是不是原生sql,下面的是实体对象名和属性,不是表名,不带下划线
    * @Param: [userId] 
    * @return: com.example.springbootjpa.entity.UcUserAccountNet 
    */ 
    @Query("select o from UcUserAccountNet o where o.userId=?1")
    UcUserAccountNet findById(long userId);

    @Query(nativeQuery = true,value = "select user_name from uc_user_account_net where user_id=?1")
    String findNameById(long userId);

    @Query(nativeQuery = true,value = "select user_name userName,name_key nameKey from uc_user_account_net where user_id=?1")
    Map<String,String> findMapById(long userId);
}
